<?php
namespace Admin\Logic;

use Think\Log;

class CashierLogic
{

    public static function getOrder()
    {


        $token = 'yibmnt1511770872';
        $suc_id = [];


        $cid=1100;
        $startTime = strtotime(date('Y-m-d').' 00:00:00');
        $endTime = strtotime(date('Y-m-d').' 23:59:59');
        $tm=time();

        $str=md5($tm.'jdgldd102ssssss'.'yibmnt1511770872'.$cid);

        $url = "http://vip.vcdes.com/index.php?g=Webs&m=Vdingdan&a=orders&token=$token&cid=$cid&str=$str&tm=$tm&st[]=".$startTime."&st[]=".$endTime."";

        $result = http_request($url); //获取源数据

        // $result = mb_substr($result, 5);   //去除源数据的<pre>标签
        if(!$result){
            return false;
        }

        $data = json_decode($result, true); //转数组

        foreach ($data as $key => &$value) {
            $value['info'] = unserialize($value['info']);  //把菜谱反序列化回来成数组
        }
        return $data;
    }

    public static function getYyTableData($table_id)
    {
        $cid=1100;
        $tm=time();
        $str=md5($tm.'jdgldd102ssssss'.'yibmnt1511770872'.$cid);
        $tableid=515;
        $timestamp = mktime(0, 0, 0, date('m'), date('d'), date('Y'));

        //餐台列表信息
        $table_url = "http://vip.vcdes.com/index.php?g=Webs&m=Vdingdan&a=detail&token=yibmnt1511770872&cid=$cid&str=$str&tm=$tm";

        $table_json = http_request($table_url);

        $res = json_decode($table_json,true);
        return $res;
    }

    public static function getYyTableId()
    {
        $cid=1100;
        $tm=time();
        $str=md5($tm.'jdgldd102ssssss'.'yibmnt1511770872'.$cid);
        $tableid=515;
        $timestamp = mktime(0, 0, 0, date('m'), date('d'), date('Y'));

        //餐台列表信息
        $table_url = "http://vip.vcdes.com/index.php?g=Webs&m=Vdingdan&a=detail&token=yibmnt1511770872&cid=$cid&str=$str&tm=$tm";

        $table_json = http_request($table_url);


        $res = json_decode($table_json,true);
        $arr = [];
        foreach ($res as $k=>$v){
            $arr[] = $v['tableid'];
        }
        return $arr;


    }


}